package com.example.demoredisspringboot.exception;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

/**
 * <b><code>GlobalException</code></b>
 * <p>
 * Description
 * <p>
 * <b>Create Time:</b> 2022/5/18 9:34.
 *
 * @author qd.yt
 * @version 0.0.1
 * @since demo-redis-springboot v0.0.1
 */
@RestControllerAdvice
public class GlobalException {
    @ExceptionHandler(ServiceException.class)
    public Map<String,Object> serviceException(ServiceException e) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("status", 500);
        map.put("message", e.getMessage());
        return map;
    }
}

